]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
magnifier: Only connect to signals when ZoomRegion is active
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Wed, 27 Mar 2019 21:57:33 +0000 (22:57 +0100)
committerMarco Trevisan (Treviño) <mail@3v1n0.net>
Wed, 27 Mar 2019 23:38:42 +0000 (00:38 +0100)
There's no need to listen signals when the zoom region is inactive, so let's
just connect/disconnect them.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/472

js/ui/magnifier.js

index a059ee98f1ca46270f58a31041012cbb18546cc2..ba7227d67df206fd67f3b5b8e501ddc44ec0e026 100644 (file)
@@ -754,13 +754,29 @@ var ZoomRegion = class ZoomRegion {
 
         this._pointerIdleMonitor = Meta.IdleMonitor.get_for_device(Meta.VIRTUAL_CORE_POINTER_ID);
         this._scrollContentsTimerId = 0;
+    }
 
-        Main.layoutManager.connect('monitors-changed',
-                                   this._monitorsChanged.bind(this));
-        this._focusCaretTracker.connect('caret-moved',
-                                    this._updateCaret.bind(this));
-        this._focusCaretTracker.connect('focus-changed',
-                                    this._updateFocus.bind(this));
+    _connectSignals() {
+        if (this._signalConnections)
+            return;
+
+        this._signalConnections = [];
+        let id = Main.layoutManager.connect('monitors-changed',
+                                            this._monitorsChanged.bind(this));
+        this._signalConnections.push([Main.layoutManager, id]);
+
+        id = this._focusCaretTracker.connect('caret-moved', this._updateCaret.bind(this));
+        this._signalConnections.push([this._focusCaretTracker, id]);
+
+        id = this._focusCaretTracker.connect('focus-changed', this._updateFocus.bind(this));
+        this._signalConnections.push([this._focusCaretTracker, id]);
+    }
+
+    _disconnectSignals() {
+        for (let [obj, id] of this._signalConnections)
+            obj.disconnect(id);
+
+        delete this._signalConnections;
     }
 
     _updateScreenPosition() {
@@ -824,7 +840,9 @@ var ZoomRegion = class ZoomRegion {
             this._updateMagViewGeometry();
             this._updateCloneGeometry();
             this._updateMousePosition();
+            this._connectSignals();
         } else {
+            this._disconnectSignals();
             this._destroyActors();
         }
 
@@ -1574,9 +1592,6 @@ var ZoomRegion = class ZoomRegion {
     }
 
     _monitorsChanged() {
-        if (!this.isActive())
-            return;
-
         this._background.set_size(global.screen_width, global.screen_height);
         this._updateScreenPosition();
     }